<html>
<head>
<link href="../style/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<p class="heading"> Core Module (last update 10/03/02) </p>
<p class="subheading">
Description:
</p>
<p> This module houses the core routines as well as several non game specific 
  functions and global variables. Notice all core functions are prefixed with 
  Gl_. The functions that are called automatically are detailed here for development 
  reasons only. They have no application other than to initialize the library. 
  The use of this module is mandatory. </p>
<p><b>UPDATE:</b><br>
  A modification to the main loop was made by <a href="http://www.def-logic.com" target="_blank">Brent 
  Silby</a> 2002. This modification replaced the setInterval with setTimeout to 
  cycle the loop. The reason for this change was to bring about more consistent 
  speed when used with Windows98 machines.</p>
<p class="subheading">
To use:
</p>
<p>
This module must be the first linked into your
script by adding this line to the &lt;HEAD&gt;
section of your document:
</p>
<p class="jcode">
&lt;script language="Javascript" src="gamelib_core.js"&gt;&lt;/script&gt;
</p>

<p class="subheading">
List of functions for core module
</p>

<p>
<a href="#GLcalibrate">Gl_calibrate()</a><br>
<a href="#GLcookie">Gl_cookie()</a><br>
<a href="#GLgetbrowser">Gl_getBrowser()</a><br>
<a href="#GLgetcookies">Gl_get_cookies()</a><br>
<a href="#GLgetwindowheight">Gl_get_window_height()</a><br>
<a href="#GLgetwindowscrollx">Gl_get_window_scrollX()</a><br>
<a href="#GLgetwindowscrolly">Gl_get_window_scrollY()</a><br>
<a href="#GLgetwindowwidth">Gl_get_window_width()</a><br>
<a href="#GLhook">Gl_hook(fnc)</a><br>
<a href="#GLlayer">Gl_layer()</a><br>
<a href="#GLmakedegs">Gl_makedegs()</a><br>
<a href="#GLpreloader">Gl_preloader(img)</a><br>
<a href="#GLscrollwindow">Gl_scrollWindow()</a><br>
<a href="#GLscrollbars">Gl_scrollbars()</a><br>
<a href="#GLsettimerspeed">Gl_setTimerSpeed()</a><br>
<a href="#GLstart">Gl_start()</a><br>
<a href="#GLstop">Gl_stop()</a><br>
<a href="#GLunhook">Gl_unhook(fnc)</a><br>
</p>

<p class="subheading">
List of Global properties for core module
</p>

<p>
<a href="#GLcos">Gl_cos</a><br>
<a href="#GLfailure">Gl_failure</a><br>
<a href="#GLloadwait">Gl_loadwait</a><br>
<a href="#GLpreimage">Gl_preimage</a><br>
<a href="#GLsin">Gl_sin</a><br>
<a href="#GLticker">Gl_ticker=0</a><br>
<a href="#GLtotalpreimages">Gl_totalpreimages</a><br>
<a href="#GLversion">Gl_version</a><br>
</p>


<p class="subheading">
Descriptions of functions
</p>

<table>
<tr>
<th>Function</th><th NOWRAP>Parameters</th><th>Description</th>
</tr>
<tr>
<a name="GLcalibrate"></a>
<td>Gl_calibrate</td><td>String, Numeric</td>
<td>This function should be used before <a href="#GLstart">Gl_start</a> is called. Its purpose is to make your game/animation run at X frames per second, no matter what browser, or CPU the script is running on! The parameters passed are the function to call when the calibration is complete, and the frames per second at which you wish the script to run.</td>
</tr>
<tr>
<a name="GLcookie"></a>
<td>Gl_cookie</td><td>String</td><td>Constructor for a cookie. Various methods and properties. Usage explained in <a href="cookiedoc.html">cookie docs</a></td>
</tr>
<tr>
<a name="GLgetbrowser"></a>
<td>Gl_getbrowser</td><td>(none)</td><td>Constructor for the <a href="#GLbrowser">Gl_browser</a> object. Called automatically. Checks for compatible browsers on startup, if <a href="#GLbrowser">Gl_browser.panic</a> is true then the visitor is using an unsupported browser. There are various other properties, used internally.</td>
</tr>
<tr>
<a name="GLgetcookies"></a>
<td>Gl_get_cookies</td><td>(none)</td><td>Called automatically. Fills GL_cookies array with cookie name/value pairs</td>
</tr>
<tr>
<a name="GLgetwindowheight"></a>
<td>Gl_get_window_height</td><td>(none)</td><td>Returns the browser window height</td>
</tr>
<tr>
<a name="GLgetwindowscrollx"></a>
<td>Gl_get_window_scrollX</td><td>(none)</td><td>Returns the amount window is scrolled in the X axis</td>
</tr>
<tr>
<a name="GLgetwindowscrolly"></a>
<td>Gl_get_window_scrollY</td><td>(none)</td><td>Returns the amount window is scrolled in the Y axis</td>
</tr>
<tr>
<a name="GLgetwindowwidth"></a>
<td>Gl_get_window_width</td><td>(none)</td><td>Returns the browser window width</td>
</tr>
<tr>
<a name="GLhook"></a>
<td>Gl_hook</td><td>String</td><td>Hooks a function to the gamelib timer loop. The string passed is the actual name of the function to be hooked. This function is very useful for tying your functions into the gamelib engine, which will keep things in sync and remove the need for other timers which take valuable CPU cycles</td>
</tr>
<tr>
<a name="GLlayer"></a>
<td>Gl_layer</td><td>Numeric, Numeric, Numeric, String</td><td>Layer constructor, read the <a href="layerdoc.html">layer docs</a> for further details</td>
</tr>
<tr>
<a name="GLmakedegs"></a>
<td>Gl_makedegs</td><td>(none)</td><td>Called automatically. Fills Gl_sin and Gl_cos arrays at startup</td>
</tr>
<tr>
<a name="GLpreloader"></a>
<td>Gl_preloader</td><td>String[...]</td><td>Used to preload images. This function can be passed any number of strings specifying image URLs (ie: "images/picture.gif","images/anotherpic.gif"). Fills an array called <a href="#GLpreimage">Gl_preimage</a>. Also updates <a href="#GLtotalpreimages">Gl_totalpreimages</a> with number of images preloaded</td>
</tr>
<tr>
<a name="GLscrollbars"></a>
<td>Gl_scrollbars</td><td>String</td><td>Turns browser scrollbars on or off for page or frame script is in. String is either "on" or "off". * Note: Only works with Internet Explorer.</td>
</tr>
<tr>
<a name="GLscrollwindow"></a>
<td>Gl_scrollWindow</td><td>Numeric, Numeric</td><td>
		Scrolls the browser window by x,y where x is first argument and y is second.
		You cannot scroll past the edges of the document!<br /><br />Be aware that Netscape/Mozilla
		browsers require scrollbars in the window for scrolling to work. This can be overcome
		with Mozilla/Netscape 6 by creating a frameset with the game's frame having the
		scrollbars switched off. Then inside this frame, place an iframe, sized bigger than
		the outer frame, so its scrollbars cannot be seen. Your script will be inside this
		iframe. You can then scroll the iframe window using this method, and to a player,
		it will look just like a normal frame being scrolled - a la IE4/5! The advantage of
		using this scroll method, rather than moving all the sprites is that it uses the
		computer's hardware scrolling, and so is very fast and smooth!
</td>
</tr>
<tr>
<a name="GLsettimerspeed"></a>
<td>Gl_setTimerSpeed</td><td>Numeric</td><td>
		NOTE: This function is deprecated. Please use <a href="#Glcalibrate">Gl_calibrate</a> instead.<br><br>
		Set the timer speed. This will affect the speed the gamelib runs at, based on
		1/1000ths of a second between screen updates. Default is 50 (20 frames per second),
		since it seems the optimum speed for the wide range of speed of PCs/Macs out there.
		Sure, you can run the gamelib at some insane speed on a dual P3 800mhz by setting
		this to 1, but you'll annoy people with slower machines unless you have simple
		(for the CPU) animation
</td>
</tr>
<tr>
<a name="GLstart"></a>
<td>Gl_start</td><td>(none)</td><td>Starts the gamelib timer loop. Sprites will not operate until this has been called</td>
</tr>
<tr>
<a name="GLstop"></a>
<td>Gl_stop</td><td>(none)</td><td>Stops the gamelib timer loop. All game functions and animation will cease</td>
</tr>
<tr>
<a name="GLunhook"></a>
<td>Gl_unhook</td><td>String</td><td>Unhooks a function. Pass it a string containing the name of the function to unhook</td>

</tr>
</table>


<p class="subheading">
Descriptions of Global properties
</p>

<table>
<tr>
<th>Property</th><th NOWRAP>Data Type</th><th NOWRAP>Read/Write<th>Description</th>
</tr>
<tr>
<a name="GLbrowser"></a>
<td>Gl_browser</td><td>Object</td><td>R</td><td>Created when core file is loaded. This checks the browser, to see if it will work with gamelib and sets various properties depending on what it finds. The most important property is Gl_browser.panic which is true if the browser cannot run gamelib scripts. You should check for this first in your game/animation to ensure the visitor is not flooded with errors!</td>
</tr>
<tr>
<a name="GLcos"></a>
<td>Gl_cos</td><td>Numeric Array</td><td>R</td><td>Holds 360 elements (0-359). Degrees of circle</td>
</tr>
<tr>
<a name="GLfailure"></a>
<td>Gl_failure</td><td>Boolean</td><td>R</td><td>Set to true if the gamelib cannot operate. Normally this is because the browser is not dynamic</td>
</tr>
<tr>
<a name="GLloadwait"></a>
<td>Gl_loadwait</td><td>Object</td><td>R</td><td>
			NOTE The Gl_loadWait property is deprecated. The starting with version 1.998,
			gamelib uses an internal queue to manage the loading of multiple layers,
			and so this property will now always be null.<br><br>
			If NOT null, then a layer is loading external content.
			Only 1 layer can load from an external file at a time, so check this
			is null before attempting to load into a layer. If a layer is loading
			and you attempt to load another, it will simply not load. See the
			<a href="layerdoc.html">layer docs</a> for more information about layers.
</td>
</tr>
<tr>
<a name="GLpreimage"></a>
<td>Gl_preimage</td><td>Image array</td><td>R</td><td>Holds preloaded images. First image that was preloaded at position [0]</td>
</tr>
<tr>
<a name="GLsin"></a>
<td>Gl_sin</td><td>Numeric Array</td><td>R</td><td>Holds 360 elements (0-359). Degrees of circle</td>
</tr>
<tr>
<a name="GLticker"></a>
<td>Gl_ticker</td><td>Numeric</td><td>R/W</td><td>Increments by 1 for each game timer loop. Use as you wish</td>
</tr>
<tr>
<a name="GLtotalpreimages"></a>
<td>Gl_totalpreimages</td><td>Numeric</td><td>R</td><td>Holds total images preloaded by <a href="#GLpreloader">Gl_preloader()</a></td>
</tr>
<tr>
<a name="GLversion"></a>
<td>Gl_version</td><td>Numeric</td><td>R</td><td>The version number of the gamelib library</td>
</tr>
</table>

</body>
</html>